//
//  UpperKeyboardView.m
//  WDFans
//
//  Created by Zhihong Yuan on 2/15/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "UpperKeyboardView.h"


@implementation UpperKeyboardView

@synthesize delegate,imgButton;

- (void)dealloc
{
    [imgButton release];
    [super dealloc];
}

- (IBAction)buttonClicked:(UIButton *)button
{
    [delegate didUpperKeyBoardButtonClick:button];
}

- (void)resetOffsetOfButtons
{
    CGFloat gap;
    
    if(nil == [imgButton imageForState:UIControlStateNormal])
    {
        imgButton.hidden = YES;
        gap = (self.frame.size.width - imgButton.frame.size.width*3)/4.f;
    }  
    else
    {
        imgButton.hidden = NO;
        gap = (self.frame.size.width - imgButton.frame.size.width*4)/5.f;
    }
    for(UIView *v in [self subviews])
    {
        if([v isKindOfClass:[UIButton class]])
        {
            CGRect rect = v.frame;
            rect.origin.x = gap*(v.tag+1) +(v.tag)*imgButton.frame.size.width;
            v.frame = rect;
        }
    }
}
@end
